package com.example.MyThread.ThreadTest05;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.MyThread.ThreadTest05
 * @Description
 * @date 2023-12-10 21:03
 */
public class MyThread extends Thread {
    static int piao = 0;
    static Object obj = new Object();

    @Override
    public void run() {
        while (true) {
            synchronized (obj) {
                if (piao < 100) {
                    piao++;
                    System.out.println(getName() + " 卖出票数：" + piao);
                } else {
                    break;
                }
            }
        }
    }
}
